import os
import sys


def minNum(a: int, b: int):
    max_num = max(a, b)
    min_num = min(a, b)
    while min_num != max_num and min_num != 0:
        t = max_num % min_num
        max_num = min_num
        min_num = t
    return max_num


n = int(input())
a = []
flag = False
for i in range(n):
    e = int(input())
    if not flag:
        k = set()
        for j in range(len(a)):
            x = minNum(a[j], e)
            y = []
            flag1 = True
            for l in k:
                if l != x:
                    if l % x == 0:
                        y.append(l)
                    elif x % l == 0:
                        flag1 = False
                    else:
                        continue
            for l in y:
                k.remove(l)
            if flag1:
                k.add(x)
        if 1 in k or len(k) > 1:
            flag = True
    a.append(e)


def solve():
    global a, n
    dp = [[False] * (min(a) * max(a) + 1)]
    for i in range(1, n + 1):
        x = []
        for j in range(len(dp[0])):
            if j >= a[i - 1] and j % a[i - 1] == 0:
                x.append(True)
            else:
                k = 0
                flag = False
                while j > k * a[i - 1]:
                    d = j - k * a[i - 1]
                    if dp[i - 1][d]:
                        x.append(True)
                        flag = True
                        break
                    k += 1
                if not flag: x.append(False)
        dp.append(x)
    return dp


if flag:
    ans = solve()
    print(ans[-1].count(False) - 1)
else:
    print('INF')
